package zhuyun.code.launcheractivity.model

import io.reactivex.observers.DisposableObserver
import zhuyun.code.launcheractivity.model.data.BaseResponse

/**
 * @author: Administrator
 * @date: 2021/11/17
 */
abstract class ResponseDataHandler<T>:DisposableObserver<BaseResponse<T>>(){
    override fun onComplete() {
    }

    override fun onNext(t: BaseResponse<T>) {
        val resultCode = t.ErrNum
        if(resultCode == 200){
            val data = t.ResultData
            onSuccess(data,t)
        } else {
            val errMsg = t.Msg
            onFailure(errMsg)
        }
    }

    override fun onError(e: Throwable) {
        val i = 0
    }
    abstract fun onSuccess(resultData:T?,baseResponse:BaseResponse<T>)
    abstract fun onFailure(errMsg:String?)
}